import React, { Component } from "react";
import { Form, Input, DatePicker, Select, Modal } from "antd";
import moment from "moment";
import "moment/locale/zh-cn";
moment.locale("zh-cn");
class EditForm extends Component {
    render() {
        const { visible, onCancel, onOk, form, confirmLoading, currentRowData } = this.props;
        const { getFieldDecorator } = form;
        const { suggestionId, userId, suggestionTime, suggestionStatus, suggestionContent } =
            currentRowData;
        const formItemLayout = {
            labelCol: {
                sm: { span: 4 },
            },
            wrapperCol: {
                sm: { span: 16 },
            },
        };
        // console.log(currentRowData)
        return (
            <Modal
                title="编辑"
                visible={visible}
                onCancel={onCancel}
                onOk={onOk}
                confirmLoading={confirmLoading}
            >
                <Form {...formItemLayout}>
                    <Form.Item label="序号:">
                        {getFieldDecorator("id", {
                            initialValue: suggestionId,
                        })(<Input disabled />)}
                    </Form.Item>
                    <Form.Item label="用户ID:">
                        {getFieldDecorator("author", {
                            initialValue: userId,
                        })(<Input disabled />)}
                    </Form.Item>
                    <Form.Item label="意见内容:">
                        {getFieldDecorator("title", {
                            initialValue: suggestionContent,
                        })(<Input placeholder="标题" disabled />)}
                    </Form.Item>
                    <Form.Item label="状态:">
                        {getFieldDecorator("status", {
                            initialValue: suggestionStatus,
                        })(
                            <Select style={{ width: 120 }}>
                                <Select.Option value="read">read</Select.Option>
                                <Select.Option value="unread" selected>
                                    unread
                                </Select.Option>
                            </Select>
                        )}
                    </Form.Item>
                    <Form.Item label="时间:">
                        {getFieldDecorator("date", {
                            rules: [{ type: "object", required: true, message: "请选择时间!" }],
                            initialValue: moment(
                                suggestionTime || "YYYY年MM月DD日",
                                "YYYY年MM月DD日"
                            ),
                        })(<DatePicker showTime format="YYYY年MM月DD日" disabled />)}
                    </Form.Item>
                </Form>
            </Modal>
        );
    }
}

export default Form.create({ name: "EditForm" })(EditForm);
